package com.ifkytek.ninegridview;

import android.app.DialogFragment;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;

public class MyWheelViewDialog extends DialogFragment {

    private static final String MyLenght = "MyWheelViewDialogColumn";
    private MyWheelViewDialogAdapter myWheelViewDialogAdapter;

    public static MyWheelViewDialog newInstance(int length){
        MyWheelViewDialog myWheelViewDialog = new MyWheelViewDialog();
        Bundle bundle = new Bundle();
        bundle.putInt(MyLenght,length);
        myWheelViewDialog.setArguments(bundle);
        return myWheelViewDialog;
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(STYLE_NORMAL, R.style.Dialog_FullScreen);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_wheel_view, container);
        //添加这一行
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        RecyclerView recyclerView = view.findViewById(R.id.rv_list);
        CustomGridLayoutManager gridLayoutManager = new CustomGridLayoutManager(getActivity(), 3);
        gridLayoutManager.setScrollEnabled(false);
        recyclerView.setLayoutManager(gridLayoutManager);
        ArrayList<WheelData> wheelData = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            wheelData.add(new WheelData());
        }
        myWheelViewDialogAdapter = new MyWheelViewDialogAdapter(R.layout.item_wheels, wheelData);
        recyclerView.setAdapter(myWheelViewDialogAdapter);
        view.findViewById(R.id.view_dismiss).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                MyWheelViewDialog.this.dismiss();
            }
        });

    }



    private class MyWheelViewDialogAdapter extends BaseQuickAdapter<WheelData,BaseViewHolder>{

        public MyWheelViewDialogAdapter(int layoutResId, @Nullable List<WheelData> data) {
            super(layoutResId, data);
        }

        @Override
        protected void convert(BaseViewHolder helper, WheelData item) {

        }
    }

    private class WheelData{

    }
}
